import { Module, forwardRef } from '@nestjs/common';
import { APP_GUARD } from '@nestjs/core';
import { PermissionsGuard } from './permission.guard';
import { SequelizeModule } from '@nestjs/sequelize';
import { Permission } from './permission.model';
import { PermissionService } from './permission.service';
import { PermissionController } from './permission.controller';
import { UserModule } from 'src/user/user.module';
import { RoleModule } from 'src/role/role.module';

@Module({
  imports: [
    SequelizeModule.forFeature([Permission]),
    forwardRef(() => UserModule),
    forwardRef(() => RoleModule),
  ],
  providers: [
    {
      provide: APP_GUARD,
      useClass: PermissionsGuard,
    },
    PermissionService,
  ],
  exports: [PermissionService],
  controllers: [PermissionController],
})
export class PermissionModule {}
